package com.basic.modules.ykf.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.basic.common.exception.RRException;
import com.basic.common.utils.ParamsModel;
import com.basic.common.utils.ParamUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.basic.common.utils.PageUtils;
import com.basic.common.utils.Query;
import com.basic.modules.ykf.dao.YkfSubAccountRecordDao;
import com.basic.modules.ykf.entity.YkfSubAccountRecordEntity;
import com.basic.modules.ykf.service.YkfSubAccountRecordService;


@Service("ykfSubAccountRecordService")
public class YkfSubAccountRecordServiceImpl extends ServiceImpl<YkfSubAccountRecordDao, YkfSubAccountRecordEntity> implements YkfSubAccountRecordService {

    @Override
    public PageUtils queryPage(ParamsModel<YkfSubAccountRecordEntity> params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getCondition()) || ObjectUtil.isEmpty(params.getCondition().getSubAccountId())) {
            throw new RRException("参数缺失");
        }
        QueryWrapper<YkfSubAccountRecordEntity> queryWrapper = ParamUtils.createQueryWrapperByDefaultSort(params);
        IPage<YkfSubAccountRecordEntity> page = this.page(
                new Query<YkfSubAccountRecordEntity>().getPage(BeanUtil.beanToMap(params.getPage())),
                queryWrapper
        );
        return new PageUtils(page);
    }

}
